<template>
    <div class="Reject_Root">
        <Manuscript v-for="item in mockData" :key="item.id" :id="item.id" :title="item.name"
            :videoPoster="item.posterSource" :videoUrl="item.videoSource" :date="item.createTime" :author="item.uid"
            :subscribe="item.details" :partition="item.type" @PlayerVideo="VideoPlay" @Accept="AcceptUE"
            @Reject="RejectUE">
        </Manuscript>
        <my-video :id="xgPlayer" :Poster="videoPoster" :Src="videoSrc" v-if="videoNeedPlayer"
            @close-video="VideoClose"></my-video>
        <el-empty :image-size="200" v-if="emptyShow" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import Manuscript from '../../components/Manuscript.vue';
import MyVideo from '../../components/MyVideo.vue';
import {AuditWork } from '../../Net/netApi.js'
import { CustomerConfirm,CustomerMessage} from '../../Util/Confirm.js';

let videoNeedPlayer = ref(false)
let videoPoster = ref('')
let videoSrc = ref('')
let emptyShow = ref(true)
let dynamicsData = ref([])


//交互方法
const VideoPlay = (source) => {
    console.log(source);
    videoPoster.value = source.videoPoster
    videoSrc.value = source.videoUrl
    videoNeedPlayer.value = true
}

const VideoClose = () => {
    videoPoster.value = ''
    videoSrc.value = ''
    videoNeedPlayer.value = false
}

const AcceptUE = (id) => {
    CustomerConfirm('确定通过审核吗', '提示', '确定', '取消','warning', 
                    ()=>AcceptManuScript(id),()=>CustomerMessage('已取消该操作','warning'))
}

const RejectUE = (id) => {
    CustomerConfirm('确定再次驳回稿件吗', '提示', '确定', '取消', 'warning', 
                    ()=>RejectManuScript(id), ()=>CustomerMessage('已取消该操作','warning'))
}

//接口方法
const AcceptManuScript = async (id) => {
    let res = await AuditWork(id, 1)
    if (res.code == '200') {
        CustomerMessage('稿件审核通过','success',true)
        GetAllWorkList()
    }
}

const RejectManuScript = async (id) => {
    let res = await AuditWork(id, 2)
    if (res.code == '200') {
        CustomerMessage('稿件驳回成功','success',true)
        GetAllWorkList()
    }
}

</script>

<style lang='less' scoped>
.Reject_Root {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    scrollbar-width: none;
}
</style>